package edu.hawaii.duedates.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Calendar;
import org.junit.Test;
import edu.hawaii.duedates.BorrowedItem;

/**
 * Implements testing of the BorrowedItem class.
 * 
 * @author Aric West
 * @author Daniel Tian
 */
public class TestBorrowedItem {
 
  /**
   * Testing equality and inequality of BorrowedItems
   */
  @Test
  public void testNormalOperations() {
    String newTitle = "Item title";
    Calendar newDate = Calendar.getInstance();
    newDate.set(2008, Calendar.NOVEMBER, 4);
    BorrowedItem item1 = new BorrowedItem(newDate, newTitle);
    BorrowedItem item2 = new BorrowedItem(newDate, newTitle);
    BorrowedItem item3 = new BorrowedItem(newDate, "item3 title");
    assertEquals("Testing matching items", item1, item2);
    assertTrue("item1 and three not equal", !item1.equals(item3));
    
    assertEquals("Test hashCode", item1.hashCode(), item2.hashCode());
    
    String testString = "11-04-2008 | Item title";
    assertEquals("Testing toString", testString, item1.toString());
  }
}